#pragma once

#include <glad/glad.h> // 包含glad来获取所有的必须OpenGL头文件
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/type_ptr.hpp>
#include <vector>
#include <iostream>
#include <fstream>
#include <string>
#include <sstream>
#include <algorithm>
using namespace std;
#include "geometry/BlockShader.h"
#include "baseClass\Texture2D.h"
#include "baseClass\Physical.h"
#include "camera.h" 
#include <unordered_map>
#include "baseClass\GLGlobal.h"
struct BlockVertex
{
    glm::vec3 position;
    glm::vec2 uv;
    glm::vec3 normal;
    float brightnessLevel;

    BlockVertex(){position = glm::vec3(0.0f); uv = glm::vec2(0.0f); normal = glm::vec3(0.0f); brightnessLevel = 0.0f;};    
};





class BlockMesh: public Physical::Loaction
{
private:
 void setupMesh(uint32_t & VAO,  uint32_t &VBO, vector<BlockVertex>&vertices);
    /*  渲染数据  */
    uint32_t VAO;
    uint32_t VBO;
public:
    static std::vector<BlockVertex> LoadMesh_Obj(const char* path);

    unordered_map<Texture2D* , vector<BlockVertex>> Texture2D_VertexMap;
    /*  函数  */
    BlockMesh(unordered_map<Texture2D * , vector<BlockVertex>> &&Texture2D_VertexMap);

    void Render(Blockshader &shader);

    ~BlockMesh(){
        glDeleteVertexArrays(1, &VAO);
        glDeleteBuffers(1,&VBO);
    }
};  
 
    

